﻿using System;
using System.IO;

namespace seqdiag
{
    class EntryPoint
    {
        static void Main(string[] args)
        {
            if (args != null && args.Length > 0 && File.Exists(args[0]))
            {
                string txtFile = args[0];
                string pngFileName = Path.GetFileNameWithoutExtension(txtFile) + ".png";

                SequenceDiagram
                    .FromFile(txtFile)
                    .Save(pngFileName);
            }
            else
            {
                foreach (string txtFile in Directory.GetFiles(Environment.CurrentDirectory, "*.txt"))
                {
                    string pngFileName = Path.GetFileNameWithoutExtension(txtFile) + ".png";

                    SequenceDiagram
                        .FromFile(txtFile)
                        .Save(pngFileName);
                }
            }
        }
    }
}
